<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>note-code</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.js"></script>
  </head>

  <body>
    <div class="container"></div>

    <script>
      const base = { weight: '50kg', age: 18, hobby: ['eating', 'drinking'] }

      const Bob = _.cloneDeep(base) // 使用 lodash 的深拷贝

      Bob.age = 20
      Bob.hobby.push('coding')

      console.log(base) //=> { weight: '50kg', age: 18, hobby: [ 'eating', 'drinking' ] }
      console.log(Bob) //=> { weight: '50kg', age: 20, hobby: [ 'eating', 'drinking', 'coding' ] }
    </script>
  </body>
</html>
